<?php

namespace App\Http\Controllers\Api;

use App\SubTwo;
use App\Video;
use Illuminate\Http\Request;


class SubTwoController extends Controller
{
    public function CarCompulsory()
    {
        $list = SubTwo::where('pid',1)->get();
        return $this->response->array([
            'code'=>200,
            'message'=>'ok',
            'data'=>$list,
        ]);
    }


    public function TheCompulsory()
    {
        $list = SubTwo::where('pid',2)->get();
        return $this->response->array([
            'code'=>200,
            'message'=>'ok',
            'data'=>$list,
        ]);
    }


    public function IntroductoryKnowledge()
    {
        $list = SubTwo::where('pid',3)->get();
        return $this->response->array([
            'code'=>200,
            'message'=>'ok',
            'data'=>$list,
        ]);
    }


    public function GetVideoInfos(Request $request)
    {
        $level2 = $request->input('level2');
        $list = Video::with('image')->where('level2',$level2)->get();
        foreach ($list as $k=>$v){
            $list[$k]['file'] = '/aetherupload/display/'.$v['file'];
            $list[$k]['txt'] = 'GetVideoInfo/'.$v['id'];
        }
        return $this->response->array([
            'code'=>200,
            'message'=>'ok',
            'data'=>$list,
        ]);
    }


}
